// pages/order/list/index.js
import { reqOrderList } from '@/api/orderpay'
Page({
  // 页面的初始数据
  data: {
    orderList: [],
    page: 1,
    limit: 10,
    total: 0
  },
  async getOrderList() {
    const { page, limit } = this.data
    const res = await reqOrderList(page, limit)
    // console.log(res)
    this.setData({
      orderList: [...this.data.orderList, ...res.data.records],
      total: res.data.total
    })
  },
  onReachBottom() {
    const { orderList, page, total } = this.data
    if (total === orderList.length) {
      wx.toast({
        title: '加载完毕'
      })
      return
    }
    this.setData({
      page: page + 1
    })
    this.getOrderList()
  },

  onLoad() {
    this.getOrderList()
  }
})
